﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Runtime.InteropServices;
using System;

namespace Client
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : WindowOwnerN
    {
        public Window1()
        {
            InitializeComponent();
            Content = new MainMenu();
        }
    }

    public class WindowOwnerN : Window
    {
        protected override void OnStateChanged(EventArgs e)
        {
            base.OnStateChanged(e);
            switch (this.WindowState)
            {
                case WindowState.Maximized:
                    ShowOwnedWindows(this);
                    break;
                case WindowState.Minimized:
                    HideOwnedWindows(this);
                    break;
                case WindowState.Normal:
                    ShowOwnedWindows(this);
                    break;
                default:
                    break;
            }
        }

        private void ShowOwnedWindows(Window window1)
        {
            foreach (Window window2 in window1.OwnedWindows)
            {
                window2.Show();
                ShowOwnedWindows(window2);
            }
        }

        private void HideOwnedWindows(Window window1)
        {
            foreach (Window window2 in window1.OwnedWindows)
            {
                window2.Hide();
                HideOwnedWindows(window2);
            }
        }
    }
}